﻿'use strict';

var app = app || {}; // establish application global namespace

app.CLIENT_ID = '539005674085';
app.API_KEY = 'AIzaSyBA5a8ztNhkxg2ILV54dHpJzJqrYM7NUKQ';
app.SCOPES = 'https://www.googleapis.com/auth/userinfo.email' +
             ' https://www.googleapis.com/auth/userinfo.profile';
app.RESPONSE_TYPE = 'token id_token';
app.API_ROOT = 'https://crmdnaweb.appspot.com/_ah/api';
app.CookieValue = 'LOGGED-IN';

// Declare app level module which depends on filters, and services
// Module
app.ishaCrmApp = angular.module('ishaCrmApp', [
  'ngRoute',
  'ishaCrmApp.filters',
  'ishaCrmApp.services',
  'ishaCrmApp.directives',
  'ishaCrmApp.controllers'
])

/*app.ishaCrmApp.config(['$routeProvider', function ($routeProvider) {
    //$routeProvider.when('/view1', { templateUrl: 'partials/partial1.html', controller: 'MyCtrl1' });
    //$routeProvider.when('/view2', { templateUrl: 'partials/partial2.html', controller: 'MyCtrl2' });
    //$routeProvider.otherwise({ redirectTo: '/' });
}]);*/

function init() {
    var apisToLoad = 2; // must match number of calls to gapi.client.load()
    var callback = function () {
        if (--apisToLoad == 0) {
            angular.bootstrap(document, ['ishaCrmApp']);
            $('#divBody').removeClass('hidden');
        }
    }
    gapi.client.load('crmdna', 'v1', callback, app.API_ROOT);
    gapi.client.load('oauth2', 'v2', callback);
};